package com.webchat.pgc.controller.sys;

import com.webchat.common.bean.APIPageResponseBean;
import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.domain.vo.request.sys.SysDataDictionaryCategoryRequestVO;
import com.webchat.domain.vo.response.sys.SysDataDictionaryCategoryBaseVO;
import com.webchat.pgc.service.sys.SysDataDictionaryCategoryService;
import com.webchat.rmi.pgc.sys.SysDataDictionaryCategoryClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据字典分类 控制器
 *
 * @author SongRenShuo
 * @date 2025/06/25
 */
@RestController
public class SysDataDictionaryCategoryController implements SysDataDictionaryCategoryClient {


    @Autowired
    private SysDataDictionaryCategoryService sysDataDictionaryCategoryService;


    /**
     * 创建或者更新数据字典分类
     *
     * @param requestVO 请求 VO
     * @return {@link APIResponseBean }<{@link Long }>
     */
    @Override
    public APIResponseBean<Long> save(@RequestBody SysDataDictionaryCategoryRequestVO requestVO) {
        Long categoryId = sysDataDictionaryCategoryService.save(requestVO);
        return APIResponseBeanUtil.success(categoryId);
    }

    /**
     * 删除数据
     *
     * @param categoryId 主键
     * @param userId     用户ID
     * @return {@link APIResponseBean }<{@link Boolean }>
     */
    @Override
    public APIResponseBean<Boolean> delete(@PathVariable Long categoryId,@PathVariable String userId) {
        boolean res = sysDataDictionaryCategoryService.delete(categoryId,userId);
        return APIResponseBeanUtil.success(res);
    }

    /**
     * 分页查询
     *
     * @param code     编号
     * @param name     名称
     * @param pageNo   页码
     * @param pageSize 每页条数
     * @return {@link APIPageResponseBean }<{@link SysDataDictionaryCategoryBaseVO }>
     */
    @Override
    public APIPageResponseBean<SysDataDictionaryCategoryBaseVO> page(String code, String name, Integer pageNo, Integer pageSize) {

        return sysDataDictionaryCategoryService.page(code, name, pageNo, pageSize);
    }

    /**
     * 列表查询 - 数据字典分类
     *
     * @return {@link APIResponseBean }<{@link List }<{@link SysDataDictionaryCategoryBaseVO }>>
     */
    @Override
    public APIResponseBean<List<SysDataDictionaryCategoryBaseVO>> list() {
        List<SysDataDictionaryCategoryBaseVO> vos = sysDataDictionaryCategoryService.list();
        return APIResponseBeanUtil.success(vos);
    }

}
